package org.zoomdev.zoom.common.caster;

class WrapPrimitiveValueCaster implements ValueCaster {
    private final ValueCaster caster;
    private final Class<?> type;

    WrapPrimitiveValueCaster(ValueCaster caster, Class<?> toType) {
        this.caster = caster;
        this.type = toType;
    }

    @Override
    public Object to(Object src) {
        if (src == null) {
            return Caster.getDefaultValue(type);
        }
        return caster.to(src);
    }
}
